


#include "time.h" 


int ChanceDate(char* date)
{
   char temp[6][20]={0};
   int  sum[5];
   int i=0,j=0;
   
  while( *date!='\0' || (*date!=' ' && *date!='\0'))
  {
  
  	temp[j][i++]=*date;
  	date++;
  	
   if(*date==' ') 
   {
   	temp[j][i]='\0';
   	j++;
   	date++;
   	i=0;
   	
   }

  }


	return DayToSecond(temp[1])+TimetoTimestamp(temp[4])+YeartoSecond(temp[3])+ MonthtoSecond(temp[3],temp[2]);
}




int YeartoSecond(char* Year)    //年转秒 
{
	 int Interger,i,flag=0;
	 Interger= atoi(Year);
	 for(i=Interger;i>1970;i--)
	 {
	 		 if ((i % 4 == 0 && i % 100 != 0) || i % 400 == 0)   // 判断闰年 
	 		 {
	 		 	flag++;   //计数一共有多少个闰年 
			  } 
	 }


	return ((Interger-1970)*365+flag)*24*60*60;
	 
}

 
 
 int MonthtoSecond(char* Year,char* Month)  //月转秒 
 {

 int year=0,sum=0,temp=0;
	 year= atoi(Year);
    int i=0,j=0;
        if (strcmp(Month, "Jan") == 0)
        {
         i=1;
		}
		  else if (strcmp(Month, "Feb") == 0)
        {
         i=2;
		}
		  else if (strcmp(Month, "Mar") == 0)
        {
         i=3;
		}     
		
			  else if (strcmp(Month, "Apr") == 0)
        {
         i=4;
		}
		  else if (strcmp(Month, "May") == 0)
        {
         i=5;
		}
			  else if (strcmp(Month, "Jun") == 0)
        {
         i=6;
		}
		  else if (strcmp(Month, "Jul") == 0)
        {
         i=7;
		}
			  else if (strcmp(Month, "Aug") == 0)
        {
         i=8;
		}
		  else if (strcmp(Month, "Sep") == 0)
        {
         i=9;
		}
			  else if (strcmp(Month, "Oct") == 0)
        {
         i=10;
		}
		  else if (strcmp(Month, "Nov") == 0)
        {
         i=11;
		}
			  else if (strcmp(Month, "Dec") == 0)
        {
         i=12;
		}
		  else  
        {
       printf("error!\n");
		}

		
		for(j=1;j<=i;j++)
		{
			if((j<=8&&(j%2!=0||j==8))||(j>8&&j%2==0))
			{
				sum=sum+31;
			}
			else if(j==2)
			{
			  if (((year % 4 == 0 && year % 100 != 0) || year % 400 == 0)) 
			  {
			  		sum=sum+29;
			  }
			  else
			  {
			  		sum=sum+28;
			  }
			}
			else if(((j<=8&&(j%2==0))&&j!=2)||(j>8&&j%2!=0))
			{
			sum=sum+30;		
			}
		}

	 
	  temp=sum*24*60*60-30*24*60*60;
			  
      return temp;
 	
  } 
  
  int DayToSecond(char *Day)    //天转秒 
  {
  	 int Interger;
  	 Interger= atoi(Day);
  return Interger*24*60*60-24*60*60;
  	 
  }

int TimetoTimestamp(char* time)
{   

    int Interger[3],i=0,j=0;
    char temp[3][4]={0};
   while( *time!='\0' || (*time!=':' && *time!='\0'))
    {
     temp[j][i++]=*time;
     time++;
     
     if(*time==':') 
   {
   	temp[j][i]='\0';
   	j++;
   	time++;
   	i=0;
   	
   }

	}

    Interger[0] = atoi(temp[0]);
    Interger[1] = atoi(temp[1]);
    Interger[2] = atoi(temp[2]);
   

	return   ((Interger[0])*60*60+Interger[1]*60+ Interger[2])-8*60*60;
}
